/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package cl.zeke.pizzastore.negocio.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author taller
 */
@Entity
@Table(name = "PIZZA")
@NamedQueries({
    @NamedQuery(name = "Pizza.findAll", query = "SELECT p FROM Pizza p"),
    @NamedQuery(name = "Pizza.findByIdPizza", query = "SELECT p FROM Pizza p WHERE p.idPizza = :idPizza"),
    @NamedQuery(name = "Pizza.findByNombre", query = "SELECT p FROM Pizza p WHERE p.nombre = :nombre"),
    @NamedQuery(name = "Pizza.findByDescripcion", query = "SELECT p FROM Pizza p WHERE p.descripcion = :descripcion"),
    @NamedQuery(name = "Pizza.findByPorcGanancia", query = "SELECT p FROM Pizza p WHERE p.porcGanancia = :porcGanancia"),
    @NamedQuery(name = "Pizza.findByPorcGananciaOferta", query = "SELECT p FROM Pizza p WHERE p.porcGananciaOferta = :porcGananciaOferta"),
    @NamedQuery(name = "Pizza.findByEnOferta", query = "SELECT p FROM Pizza p WHERE p.enOferta = :enOferta")})
public class Pizza implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_PIZZA")
    private Long idPizza;
    @Basic(optional = false)
    @Column(name = "NOMBRE")
    private String nombre;
    @Column(name = "DESCRIPCION")
    private String descripcion;
    @Basic(optional = false)
    @Column(name = "PORC_GANANCIA")
    private float porcGanancia;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "PORC_GANANCIA_OFERTA")
    private Float porcGananciaOferta;
    @Column(name = "EN_OFERTA")
    private Boolean enOferta;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "pizza", fetch = FetchType.LAZY)
    private List<PizzaIngrediente> pizzaIngredienteList;
    @JoinColumn(name = "ID_ARCHIVO", referencedColumnName = "ID_ARCHIVO")
    @ManyToOne(fetch = FetchType.LAZY)
    private Archivo idArchivo;
    @JoinColumn(name = "ID_CATEGORIA_PIZZA", referencedColumnName = "ID_CATEGORIA_PIZZA")
    @ManyToOne(fetch = FetchType.LAZY)
    private CategoriaPizza idCategoriaPizza;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "pizza", fetch = FetchType.LAZY)
    private List<VentaPizza> ventaPizzaList;

    public Pizza() {
    }

    public Pizza(Long idPizza) {
        this.idPizza = idPizza;
    }

    public Pizza(Long idPizza, String nombre, float porcGanancia) {
        this.idPizza = idPizza;
        this.nombre = nombre;
        this.porcGanancia = porcGanancia;
    }

    public Long getIdPizza() {
        return idPizza;
    }

    public void setIdPizza(Long idPizza) {
        this.idPizza = idPizza;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public float getPorcGanancia() {
        return porcGanancia;
    }

    public void setPorcGanancia(float porcGanancia) {
        this.porcGanancia = porcGanancia;
    }

    public Float getPorcGananciaOferta() {
        return porcGananciaOferta;
    }

    public void setPorcGananciaOferta(Float porcGananciaOferta) {
        this.porcGananciaOferta = porcGananciaOferta;
    }

    public Boolean getEnOferta() {
        return enOferta;
    }

    public void setEnOferta(Boolean enOferta) {
        this.enOferta = enOferta;
    }

    public List<PizzaIngrediente> getPizzaIngredienteList() {
        return pizzaIngredienteList;
    }

    public void setPizzaIngredienteList(List<PizzaIngrediente> pizzaIngredienteList) {
        this.pizzaIngredienteList = pizzaIngredienteList;
    }

    public Archivo getIdArchivo() {
        return idArchivo;
    }

    public void setIdArchivo(Archivo idArchivo) {
        this.idArchivo = idArchivo;
    }

    public CategoriaPizza getIdCategoriaPizza() {
        return idCategoriaPizza;
    }

    public void setIdCategoriaPizza(CategoriaPizza idCategoriaPizza) {
        this.idCategoriaPizza = idCategoriaPizza;
    }

    public List<VentaPizza> getVentaPizzaList() {
        return ventaPizzaList;
    }

    public void setVentaPizzaList(List<VentaPizza> ventaPizzaList) {
        this.ventaPizzaList = ventaPizzaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPizza != null ? idPizza.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pizza)) {
            return false;
        }
        Pizza other = (Pizza) object;
        if ((this.idPizza == null && other.idPizza != null) || (this.idPizza != null && !this.idPizza.equals(other.idPizza))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.zeke.pizzastore.negocio.entities.Pizza[ idPizza=" + idPizza + " ]";
    }
    
}
